package com.hopes.bizz.risk.hid.service.impl;

import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.ObjectUtil;
import com.hopes.bizz.common.core.util.DateUtils;
import com.hopes.bizz.risk.common.constant.HidDicConstant;
import com.hopes.bizz.risk.common.constant.RiskDicConstant;
import com.hopes.bizz.risk.common.constant.enums.RiskHidSourceEnum;
import com.hopes.bizz.risk.common.constant.enums.RiskSysDictEnum;
import com.hopes.bizz.risk.hid.dto.RiskHidHiddenDangerStatisticsDto;
import com.hopes.bizz.risk.hid.entity.RiskHidHiddenDangerEntity;
import com.hopes.bizz.risk.hid.service.RiskHidHiddenDangerService;
import com.hopes.bizz.risk.hid.service.RiskHidHiddenDangerStatisticsService;
import com.hopes.bizz.risk.hid.vo.RiskHidHiddenDangerStatisticsColumnVo;
import com.hopes.bizz.risk.hid.vo.RiskHidHiddenDangerStatisticsTableVo;
import com.hopes.bizz.risk.hid.vo.RiskHidHiddenDangerStatisticsVo;
import com.hopes.boss.admin.api.entity.SysDictItem;
import com.hopes.boss.admin.api.resolver.DictResolver;
import com.hopes.boss.admin.api.resolver.enums.AdminDictEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.DecimalFormat;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * @author: ljh
 * @create: 2023/7/26
 */
@Service
public class RiskHidHiddenDangerStatisticsServiceImpl implements RiskHidHiddenDangerStatisticsService {


    @Autowired
    private RiskHidHiddenDangerService hidHiddenDangerService;

    private static final DecimalFormat decimalFormat = new DecimalFormat("##.0%");


    @Override
    public RiskHidHiddenDangerStatisticsVo riskPointInfoForTable(RiskHidHiddenDangerStatisticsDto queryParams) {
        List<RiskHidHiddenDangerEntity> hiddenDangers = hidHiddenDangerService.lambdaQuery()
                .ge(ObjectUtil.isNotNull(queryParams.getBeginTime()), RiskHidHiddenDangerEntity::getReportDate, queryParams.getBeginTime())
                .le(ObjectUtil.isNotNull(queryParams.getEndTime()), RiskHidHiddenDangerEntity::getReportDate, queryParams.getEndTime()).list()
                .stream()
                .filter(item -> RiskHidSourceEnum.RISK_CONTROL.getCode().equals(item.getBizCode()) && item.getRiskUnitId() != null)
                .filter(item -> {
                    if (queryParams.getRiskPointType() != null) {
                        return item.getRiskUnitType().equals(queryParams.getRiskPointType());
                    }
                    return true;
                }).collect(Collectors.toList());

        // 根据单元进行分类
        Map<String, List<RiskHidHiddenDangerEntity>> riskUnitClassify = hiddenDangers.stream()
                .filter(item -> ObjectUtil.isNotNull(item.getRiskUnitId()))
                .collect(Collectors.groupingBy(RiskHidHiddenDangerEntity::getRiskUnitIdStr));
        double sum = 0.0;// 总数
        for (String k : riskUnitClassify.keySet()) {
            sum += riskUnitClassify.get(k).size();
        }
        List<RiskHidHiddenDangerStatisticsTableVo> statisticsTableVos = new ArrayList<>();
        for (String k : riskUnitClassify.keySet()) {
            RiskHidHiddenDangerStatisticsTableVo statistics = new RiskHidHiddenDangerStatisticsTableVo();
            statistics.setLabel(k);
            statistics.setTotalNum(riskUnitClassify.get(k).size());
            statistics.setHandlePer(decimalFormat.format(riskUnitClassify.get(k).size() / sum));
            statisticsTableVos.add(statistics);
        }
        // 根据风险点进行分类
        RiskHidHiddenDangerStatisticsColumnVo hidHiddenDangerStatisticsColumnVo = new RiskHidHiddenDangerStatisticsColumnVo();
        ArrayList<String> coumnName = new ArrayList<>();
        ArrayList<Integer> equipmentList = new ArrayList<>();
        ArrayList<Integer> placeList = new ArrayList<>();
        ArrayList<Integer> jobActivityList = new ArrayList<>();
        hidHiddenDangerStatisticsColumnVo.setName(coumnName);
        hidHiddenDangerStatisticsColumnVo.setEquipment(equipmentList);
        hidHiddenDangerStatisticsColumnVo.setPlace(placeList);
        hidHiddenDangerStatisticsColumnVo.setJobActivity(jobActivityList);
        for (String riskUnit : riskUnitClassify.keySet()) {
            int equipment = 0;
            int place = 0;
            int jobActivity = 0;
            coumnName.add(riskUnit);
            List<RiskHidHiddenDangerEntity> dangerList = riskUnitClassify.get(riskUnit);
            for (RiskHidHiddenDangerEntity hiddenDanger : dangerList) {
                Integer riskUnitType = hiddenDanger.getRiskUnitType();
                if (RiskDicConstant.RISK_POINT_EQUIPMENT_TYPE.equals(riskUnitType)) {
                    // 设备设施
                    equipment += 1;
                } else if (RiskDicConstant.RISK_POINT_PLACE_TYPE.equals(riskUnitType)) {
                    // 部门场所
                    place += 1;
                } else if (RiskDicConstant.RISK_POINT_JOBACTIVITY_TYPE.equals(riskUnitType)) {
                    // 作业活动
                    jobActivity += 1;
                }
            }
            equipmentList.add(equipment);
            placeList.add(place);
            jobActivityList.add(jobActivity);

        }
        RiskHidHiddenDangerStatisticsVo hidHiddenDangerStatisticsVo = new RiskHidHiddenDangerStatisticsVo();
        hidHiddenDangerStatisticsVo.setTableData(statisticsTableVos);
        hidHiddenDangerStatisticsVo.setColumnData(hidHiddenDangerStatisticsColumnVo);

        return hidHiddenDangerStatisticsVo;
    }

    @Override
    public RiskHidHiddenDangerStatisticsVo hidTypeInfo(RiskHidHiddenDangerStatisticsDto queryParams) {

        List<RiskHidHiddenDangerEntity> hidHiddenDangers = hidHiddenDangerService.lambdaQuery()
                .ge(ObjectUtil.isNotNull(queryParams.getBeginTime()), RiskHidHiddenDangerEntity::getReportDate, queryParams.getBeginTime())
                .le(ObjectUtil.isNotNull(queryParams.getEndTime()), RiskHidHiddenDangerEntity::getReportDate, queryParams.getEndTime())
                .eq(ObjectUtil.isNotNull(queryParams.getDeptId()), RiskHidHiddenDangerEntity::getDeptId, queryParams.getDeptId())
                .eq(ObjectUtil.isNotNull(queryParams.getHidType()), RiskHidHiddenDangerEntity::getHidType, queryParams.getHidType())
                .eq(ObjectUtil.isNotNull(queryParams.getHidLevel()), RiskHidHiddenDangerEntity::getHidLevel, queryParams.getHidLevel()).list();

        // 隐患类型分类
        Map<String, List<RiskHidHiddenDangerEntity>> hidTypeClassify = hidHiddenDangers.stream()
                .filter(item -> ObjectUtil.isNotNull(item.getHidTypeStr()))
                .collect(Collectors.groupingBy(RiskHidHiddenDangerEntity::getHidTypeStr));
        List<SysDictItem> dangerType = DictResolver.getDictItemsByType(RiskSysDictEnum.danger_type.getType());
        if (ObjectUtil.isNotNull(queryParams.getHidType())){
             dangerType = dangerType.stream().filter(sysDictItem -> sysDictItem.getCode().equals(queryParams.getHidType().toString())).collect(Collectors.toList());
        }
        ArrayList<String> name = new ArrayList<>();
        ArrayList<Integer> normalLevelNum = new ArrayList<>();
        ArrayList<Integer> highLevelNum = new ArrayList<>();
        for (SysDictItem sysDictItem : dangerType) {
            String label = sysDictItem.getName();
            name.add(label);
            // 统计该危险源下，一般隐患和重大隐患的数量
            List<RiskHidHiddenDangerEntity> hiddenDangers = hidTypeClassify.get(label);
            if (CollectionUtil.isEmpty(hiddenDangers)) {
                normalLevelNum.add(0);
                highLevelNum.add(0);
            } else {
                Map<Integer, Long> map = hiddenDangers.stream().filter(item -> item.getHidLevel() != null).collect(Collectors.groupingBy(RiskHidHiddenDangerEntity::getHidLevel, Collectors.counting()));
                normalLevelNum.add(map.get(HidDicConstant.DANGER_LEVEL_GENERAL) == null ? 0 : map.get(HidDicConstant.DANGER_LEVEL_GENERAL).intValue());
                highLevelNum.add(map.get(HidDicConstant.DANGER_LEVEL_MAJOR) == null ? 0 : map.get(HidDicConstant.DANGER_LEVEL_MAJOR).intValue());
            }
        }
        RiskHidHiddenDangerStatisticsColumnVo hidHiddenDangerStatisticsColumnVo = new RiskHidHiddenDangerStatisticsColumnVo();
        hidHiddenDangerStatisticsColumnVo.setHighLevelNum(highLevelNum);
        hidHiddenDangerStatisticsColumnVo.setName(name);
        hidHiddenDangerStatisticsColumnVo.setNormalLevelNum(normalLevelNum);

        // 小于50为整改中，大于等于50为已整改
        ArrayList<RiskHidHiddenDangerStatisticsTableVo> hidHiddenDangerStatisticsTableVos = new ArrayList<>();
        for (String hidType : hidTypeClassify.keySet()) {
            RiskHidHiddenDangerStatisticsTableVo hidHiddenDangerStatisticsTableVo = new RiskHidHiddenDangerStatisticsTableVo();
            hidHiddenDangerStatisticsTableVo.setLabel(hidType);
            int handleStatusNum = 0;
            int finishStatusNum = 0;
            for (RiskHidHiddenDangerEntity hiddenDanger : hidTypeClassify.get(hidType)) {
                // 小于50为整改中
                if (hiddenDanger.getHidStatus() < HidDicConstant.HID_DANGER_STATUS_WAIT_ACCEPTANCE) {
                    handleStatusNum += 1;
                } else {
                    finishStatusNum += 1;
                }
            }
            String handlePer = decimalFormat.format((double) finishStatusNum / (handleStatusNum + finishStatusNum));
            hidHiddenDangerStatisticsTableVo.setFinishStatusNum(finishStatusNum);
            hidHiddenDangerStatisticsTableVo.setHandleStatusNum(handleStatusNum);
            hidHiddenDangerStatisticsTableVo.setHandlePer(handlePer);
            hidHiddenDangerStatisticsTableVos.add(hidHiddenDangerStatisticsTableVo);
        }
        RiskHidHiddenDangerStatisticsVo hidHiddenDangerStatisticsVo = new RiskHidHiddenDangerStatisticsVo();
        hidHiddenDangerStatisticsVo.setColumnData(hidHiddenDangerStatisticsColumnVo);
        hidHiddenDangerStatisticsVo.setTableData(hidHiddenDangerStatisticsTableVos);
        return hidHiddenDangerStatisticsVo;
    }

    @Override
    public RiskHidHiddenDangerStatisticsVo deptInfo(RiskHidHiddenDangerStatisticsDto queryParams) {

        List<RiskHidHiddenDangerEntity> hidHiddenDangers = hidHiddenDangerService.lambdaQuery()
                .ge(ObjectUtil.isNotNull(queryParams.getBeginTime()), RiskHidHiddenDangerEntity::getReportDate, queryParams.getBeginTime())
                .le(ObjectUtil.isNotNull(queryParams.getEndTime()), RiskHidHiddenDangerEntity::getReportDate, queryParams.getEndTime())
                .eq(ObjectUtil.isNotNull(queryParams.getDeptId()), RiskHidHiddenDangerEntity::getDeptId, queryParams.getDeptId())
                .eq(ObjectUtil.isNotNull(queryParams.getHidType()), RiskHidHiddenDangerEntity::getHidType, queryParams.getHidType())
                .eq(ObjectUtil.isNotNull(queryParams.getHidLevel()), RiskHidHiddenDangerEntity::getHidLevel, queryParams.getHidLevel()).list();

        // 根据责任部门分类
        Map<Long, List<RiskHidHiddenDangerEntity>> deptClassify = hidHiddenDangers.stream()
                .filter(item -> ObjectUtil.isNotNull(item.getDeptId()))
                .collect(Collectors.groupingBy(RiskHidHiddenDangerEntity::getDeptId));


        // 表格数据
        ArrayList<RiskHidHiddenDangerStatisticsTableVo> hidHiddenDangerStatisticsTableVos = new ArrayList<>();
        for (Long dept : deptClassify.keySet()) {
            RiskHidHiddenDangerStatisticsTableVo hidHiddenDangerStatisticsTableVo = new RiskHidHiddenDangerStatisticsTableVo();
            hidHiddenDangerStatisticsTableVo.setLabel(DictResolver.getItemLabelByValue(AdminDictEnum.sys_dept,dept));
            List<RiskHidHiddenDangerEntity> dangerList = deptClassify.get(dept);
            int finishStatusNum = 0;
            int normalLevelNum = 0;
            int highLevelNum = 0;
            if (CollectionUtil.isEmpty(dangerList)) {
                continue;
            } else {
                for (RiskHidHiddenDangerEntity hiddenDanger : dangerList) {
                    // 隐患状态
                    Integer hidStatus = hiddenDanger.getHidStatus();
                    // 隐患级别
                    Integer hidLevel = hiddenDanger.getHidLevel();
                    // 一般隐患
                    if (HidDicConstant.DANGER_LEVEL_GENERAL.equals(hidLevel)) {
                        normalLevelNum += 1;
                        // 重大隐患
                    }else if (HidDicConstant.DANGER_LEVEL_MAJOR.equals(hidLevel)) {
                        highLevelNum += 1;
                        // 已整改
                    }
                    if (HidDicConstant.HID_DANGER_STATUS_WAIT_ACCEPTANCE <= hidStatus) {
                        finishStatusNum += 1;
                    }
                }
            }
            String handlePer = decimalFormat.format((double) finishStatusNum / dangerList.size());
            hidHiddenDangerStatisticsTableVo.setFinishStatusNum(finishStatusNum);
            hidHiddenDangerStatisticsTableVo.setNormalLevelNum(normalLevelNum);
            hidHiddenDangerStatisticsTableVo.setHighLevelNum(highLevelNum);
            hidHiddenDangerStatisticsTableVo.setHandlePer(handlePer);
            hidHiddenDangerStatisticsTableVos.add(hidHiddenDangerStatisticsTableVo);
        }

        // 柱状图数据
        List<SysDictItem> departmentList;
        Stream<SysDictItem> itemStream = DictResolver.getItemsByType(AdminDictEnum.sys_dept).stream();
        if (ObjectUtil.isNotNull(queryParams.getDeptId())){
            departmentList = itemStream.filter(item -> item.getId().equals(queryParams.getDeptId())).collect(Collectors.toList());
        }else {
            departmentList = itemStream.collect(Collectors.toList());
        }
        ArrayList<String> name = new ArrayList<>();
        ArrayList<Integer> normalLevelNum = new ArrayList<>();
        ArrayList<Integer> highLevelNum = new ArrayList<>();
        for (SysDictItem department : departmentList) {
            String label = department.getName();
            name.add(label);
            // 统计该危险源下，一般隐患和重大隐患的数量
            List<RiskHidHiddenDangerEntity> hiddenDangers = deptClassify.get(department.getId());
            if (CollectionUtil.isEmpty(hiddenDangers)) {
                normalLevelNum.add(0);
                highLevelNum.add(0);
            } else {
                Map<Integer, Long> map = hiddenDangers.stream().filter(item -> item.getHidLevel() != null).collect(Collectors.groupingBy(RiskHidHiddenDangerEntity::getHidLevel, Collectors.counting()));
                normalLevelNum.add(map.get(HidDicConstant.DANGER_LEVEL_GENERAL) == null ? 0 : map.get(HidDicConstant.DANGER_LEVEL_GENERAL).intValue());
                highLevelNum.add(map.get(HidDicConstant.DANGER_LEVEL_MAJOR) == null ? 0 : map.get(HidDicConstant.DANGER_LEVEL_MAJOR).intValue());
            }
        }
        RiskHidHiddenDangerStatisticsColumnVo hidHiddenDangerStatisticsColumnVo = new RiskHidHiddenDangerStatisticsColumnVo();
        hidHiddenDangerStatisticsColumnVo.setHighLevelNum(highLevelNum);
        hidHiddenDangerStatisticsColumnVo.setName(name);
        hidHiddenDangerStatisticsColumnVo.setNormalLevelNum(normalLevelNum);


        RiskHidHiddenDangerStatisticsVo hidHiddenDangerStatisticsVo = new RiskHidHiddenDangerStatisticsVo();
        hidHiddenDangerStatisticsVo.setTableData(hidHiddenDangerStatisticsTableVos);
        hidHiddenDangerStatisticsVo.setColumnData(hidHiddenDangerStatisticsColumnVo);
        return hidHiddenDangerStatisticsVo;
    }

    @Override
    public RiskHidHiddenDangerStatisticsVo changeTrendInfo(RiskHidHiddenDangerStatisticsDto queryParams) {
        List<RiskHidHiddenDangerEntity> hidHiddenDangers = hidHiddenDangerService.lambdaQuery()
                .ge(ObjectUtil.isNotNull(queryParams.getBeginTime()), RiskHidHiddenDangerEntity::getReportDate, queryParams.getBeginTime())
                .le(ObjectUtil.isNotNull(queryParams.getEndTime()), RiskHidHiddenDangerEntity::getReportDate, queryParams.getEndTime())
                .eq(ObjectUtil.isNotNull(queryParams.getDeptId()), RiskHidHiddenDangerEntity::getDeptId, queryParams.getDeptId())
                .eq(ObjectUtil.isNotNull(queryParams.getHidType()), RiskHidHiddenDangerEntity::getHidType, queryParams.getHidType())
                .eq(ObjectUtil.isNotNull(queryParams.getHidLevel()), RiskHidHiddenDangerEntity::getHidLevel, queryParams.getHidLevel())
                .orderByAsc(RiskHidHiddenDangerEntity::getReportDate)
                .list();

        // 根据上报日期分类
        Map<String, List<RiskHidHiddenDangerEntity>> timeClassify = hidHiddenDangers.stream()
                .filter(item -> ObjectUtil.isNotNull(item.getReportDateDayStr()))
                .collect(Collectors.groupingBy(RiskHidHiddenDangerEntity::getReportDateDayStr, TreeMap::new,Collectors.toList())).descendingMap();

        ArrayList<RiskHidHiddenDangerStatisticsTableVo> hidHiddenDangerStatisticsTableVos = new ArrayList<>();
        // 表格数据
        for (String time : timeClassify.keySet()) {
            RiskHidHiddenDangerStatisticsTableVo hidHiddenDangerStatisticsTableVo = new RiskHidHiddenDangerStatisticsTableVo();
            hidHiddenDangerStatisticsTableVo.setLabel(time);
            List<RiskHidHiddenDangerEntity> dangerList = timeClassify.get(time);
            int normalLevelNum = 0;
            int highLevelNum = 0;
            for (RiskHidHiddenDangerEntity hiddenDanger : dangerList) {
                // 隐患级别
                Integer hidLevel = hiddenDanger.getHidLevel();
                // 一般隐患
                if (HidDicConstant.DANGER_LEVEL_GENERAL.equals(hidLevel)) {
                    normalLevelNum += 1;
                    // 重大隐患
                } else if (HidDicConstant.DANGER_LEVEL_MAJOR.equals(hidLevel)) {
                    highLevelNum += 1;
                }
            }
            hidHiddenDangerStatisticsTableVo.setNormalLevelNum(normalLevelNum);
            hidHiddenDangerStatisticsTableVo.setHighLevelNum(highLevelNum);

            hidHiddenDangerStatisticsTableVos.add(hidHiddenDangerStatisticsTableVo);
        }

        // 根据责任部门分类
        Map<Long, List<RiskHidHiddenDangerEntity>> deptClassify = hidHiddenDangers.stream()
                .filter(item -> ObjectUtil.isNotNull(item.getDeptId()))
                .collect(Collectors.groupingBy(RiskHidHiddenDangerEntity::getDeptId));
        // 柱状图数据
        List<SysDictItem> departmentList = DictResolver.getItemsByType(AdminDictEnum.sys_dept);

        ArrayList<String> name = new ArrayList<>();
        ArrayList<Integer> normalLevelNum = new ArrayList<>();
        ArrayList<Integer> highLevelNum = new ArrayList<>();
        for (SysDictItem department : departmentList) {
            String label = department.getName();
            name.add(label);
            // 统计该危险源下，一般隐患和重大隐患的数量
            List<RiskHidHiddenDangerEntity> hiddenDangers = deptClassify.get(department.getId());
            if (CollectionUtil.isEmpty(hiddenDangers)) {
                normalLevelNum.add(0);
                highLevelNum.add(0);
            } else {
                Map<Integer, Long> map = hiddenDangers.stream().filter(item -> item.getHidLevel() != null).collect(Collectors.groupingBy(RiskHidHiddenDangerEntity::getHidLevel, Collectors.counting()));
                normalLevelNum.add(map.get(HidDicConstant.DANGER_LEVEL_GENERAL) == null ? 0 : map.get(HidDicConstant.DANGER_LEVEL_GENERAL).intValue());
                highLevelNum.add(map.get(HidDicConstant.DANGER_LEVEL_MAJOR) == null ? 0 : map.get(HidDicConstant.DANGER_LEVEL_MAJOR).intValue());
            }
        }
        RiskHidHiddenDangerStatisticsColumnVo hidHiddenDangerStatisticsColumnVo = new RiskHidHiddenDangerStatisticsColumnVo();
        hidHiddenDangerStatisticsColumnVo.setHighLevelNum(highLevelNum);
        hidHiddenDangerStatisticsColumnVo.setName(name);
        hidHiddenDangerStatisticsColumnVo.setNormalLevelNum(normalLevelNum);

        RiskHidHiddenDangerStatisticsVo hidHiddenDangerStatisticsVo = new RiskHidHiddenDangerStatisticsVo();
        hidHiddenDangerStatisticsVo.setTableData(hidHiddenDangerStatisticsTableVos);
        hidHiddenDangerStatisticsVo.setColumnData(hidHiddenDangerStatisticsColumnVo);

        return hidHiddenDangerStatisticsVo;
    }

    /* 隐患整改动态 */
    @Override
    public RiskHidHiddenDangerStatisticsColumnVo hidTypeInfoYear() {
        int year = DateUtils.getYear(new Date());
        // 只统计当年一整年的数据
        final Date beginDate = DateUtils.parseDate(year + "-01-01", "");
        final Date endDate = DateUtils.parseDate(year + "-12-31", "");


        List<RiskHidHiddenDangerEntity> hiddenDangers = hidHiddenDangerService.lambdaQuery()
                .ge(ObjectUtil.isNotNull(beginDate), RiskHidHiddenDangerEntity::getReportDate, beginDate)
                .le(ObjectUtil.isNotNull(endDate), RiskHidHiddenDangerEntity::getReportDate, endDate).list();

        // 隐患类型分类
        final Map<String, List<RiskHidHiddenDangerEntity>> hidTypeClassify = hiddenDangers.stream().filter(item ->
                ObjectUtil.isNotNull(item.getHidTypeStr())).collect(Collectors.groupingBy(RiskHidHiddenDangerEntity::getHidTypeStr));

        final List<String> nameList = new ArrayList<>();
        final List<Integer> highLevelNum = new ArrayList<>();
        final List<Integer> normalLevelNum = new ArrayList<>();
        final List<Integer> finishStatusNum = new ArrayList<>();

        for (Map.Entry<String, List<RiskHidHiddenDangerEntity>> entry : hidTypeClassify.entrySet()) {
            nameList.add(entry.getKey());
            // 统计该类型下，一般隐患和重大隐患的数量
            final List<RiskHidHiddenDangerEntity> dangerList = entry.getValue();
            if (CollectionUtil.isEmpty(dangerList)) {
                highLevelNum.add(0);
                normalLevelNum.add(0);
            } else {
                final Map<Integer, Long> map = dangerList.stream().filter(e -> null != e.getHidLevel()).collect(Collectors.groupingBy(RiskHidHiddenDangerEntity::getHidLevel, Collectors.counting()));
                highLevelNum.add(MapUtil.getInt(map, HidDicConstant.DANGER_LEVEL_GENERAL, 0));
                normalLevelNum.add(MapUtil.getInt(map, HidDicConstant.DANGER_LEVEL_GENERAL, 0));
            }
            // 统计该类型下，已整改的数量
            final Long count = dangerList.stream().filter(e ->
                    ObjectUtil.isNotNull(e.getHidStatus())).filter(e ->
                    e.getHidStatus() >= HidDicConstant.HID_DANGER_STATUS_WAIT_ACCEPTANCE).count();
            finishStatusNum.add(count.intValue());
        }
        RiskHidHiddenDangerStatisticsColumnVo hidHiddenDangerStatisticsColumnVo = new RiskHidHiddenDangerStatisticsColumnVo();
        hidHiddenDangerStatisticsColumnVo.setName(nameList);
        hidHiddenDangerStatisticsColumnVo.setHighLevelNum(highLevelNum);
        hidHiddenDangerStatisticsColumnVo.setNormalLevelNum(normalLevelNum);
        hidHiddenDangerStatisticsColumnVo.setFinishStatusNum(finishStatusNum);

        return hidHiddenDangerStatisticsColumnVo;
    }
}
